package com.heima.controller;

import com.heima.common.MessageConst;
import com.heima.entity.Result;
import com.heima.pojo.User;
import com.heima.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户控制器
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping("/findAll")
    public Result findAll(){
        log.info("[用户-查询所有]……");
        // 调用service添加数据
        List<User> users = userService.findAll();
        return new Result(true, MessageConst.ACTION_SUCCESS,users);
    }
}
